Component({
    properties: {
        options:{
            type:[Object,Array,undefined],
            value: [
                {id:1, title:'是'},{id:0, title:'否'}
            ]
        },
        keyCol:{type:String,value:'title'},
        valueCol:{type:String, value:'id'},
        value: {
            type:String|Number|null, value:'',
            observer(data){
                if(data || data===0) {
                    this.setData({
                        _value:data,
                    })
                }
            }

        }
    },
    data: {
        _keys: [],
        _value:'',
    },
    lifetimes:{
        attached() {
            (async ()=>{
                const {keyCol, valueCol} = this.data
                this.setData({
                    _keys:{
                        label:keyCol,
                        value: valueCol,
                    }
                })
            })()
        }
    },
    methods: {
        change(e){
            const {value} = e.detail
            this.setData({
                _value:value,
            })
            this.triggerEvent('change', {
                value,
            })
        }
    }
});
